import axios from 'axios';
import qs from 'qs'
// 登录请求方法
const loginreq = (method, url, params) => {
    return axios({
        method: method,
        url: url,
        headers: {
            'Content-Type': 'multipart/form-data',
        },
        params: params,
    }).then(res => res);
};
// 通用公用方法
//post方向封装
const req = (url, params) => {
    return axios({
        method: "POST",
        url: url,
        headers: {
            'Content-Type': 'multipart/form-data',
            Token: localStorage.logintoken
        },
        data:params,
        paramsSerializer: params => {
             return qs.stringify(params, { indices: false })
         }
    });
};
//get方向封装
const getReq = (url,params) =>{
    return axios({
        method:"GET",
        url:url,
        headers:{
            'Content-Type': 'multipart/form-data',
            'Token': localStorage.logintoken
        },
        params:params,
        // paramsSerializer: params => {
        //     return qs.stringify(params, { indices: false })
        // }
    })
}
const getReqT = (url,params,Token) =>{
    return axios({
        method:"GET",
        url:url,
        headers:{
            'Content-Type': 'multipart/form-data',
            'Token': Token
        },
        params:params,
        // paramsSerializer: params => {
        //     return qs.stringify(params, { indices: false })
        // }
    })
}
export {
    getReq,
    loginreq,
    req,
    getReqT
}